<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

namespace App\Command;

use App\Controller\Backend\Agent;
use App\Controller\Backend\Package;
use App\Controller\Backend\Remit;
use App\Job\PushFinanacePackageNoticeJob;
use App\Job\UserLevelUpdateJob;
use App\Log\AgentLog;
use App\Log\LevelLog;
use App\Model\AgentLevel;
use App\Model\AgentOrder;
use App\Model\ChatTransact;
use App\Model\FinancePackageOrder;
use App\Model\Menu;
use App\Service\FinancePackageServer;
use App\Service\RemitServer;
use App\Service\SmsServer;
use config\runtime\container\proxy\Redis;
use Hyperf\Command\Annotation\Command;
use Hyperf\Command\Command as HyperfCommand;
use Hyperf\Utils\ApplicationContext;
use Psr\Container\ContainerInterface;
use Qiniu\Auth;

#[Command]
class MakeCleanRedisCommand extends HyperfCommand
{
    public function __construct(protected ContainerInterface $container)
    {
        parent::__construct('demo:cleanRedis');
    }

    public function configure()
    {
        parent::configure();
        $this->setDescription('清空redis');
    }

    public function handle()
    {
        // 根据前缀 获取所有的key
        $redis = ApplicationContext::getContainer()->get(Redis::class);
        $keys = $redis->keys('Remit_WebSocketGlobalController_user_id_with_fd_*');
        $fds = $redis->keys('Remit_WebSocketGlobalController_fd_with_user_id*');
        $redis->del($keys);
        $redis->del($fds);
    }
}
